#include "filereadimpl.h"

CFileReadImpl::CFileReadImpl(void)
{
	loadFileInstance(&m_FileOpt);
	m_hFile = FILE_INVALID;
}
CFileReadImpl::~CFileReadImpl(void)
{
	CloseFile();
}
//////////////////////////////////////////////////////////////////////////
std_method_impl CFileReadImpl::LoadFile(const TCHAR* pszLoadFile,
										  unsigned long ulwDesiredAccess,
										  unsigned long ulShareMode,
										  unsigned long ulCreationDisposition,
										  unsigned long ulFlagsAndAttributes)
{
	HRESULT		hr	=	S_OK;

	m_hFile = m_FileOpt.Open(pszLoadFile, O_RDWR, 0644);

	return hr;
}
std_method_impl CFileReadImpl::CloseFile()
{
	HRESULT		hr	=	S_OK;

	if (m_hFile != FILE_INVALID)
	{
		m_FileOpt.Close(m_hFile);
		m_hFile = FILE_INVALID;
	}
	return hr;
}
std_method_type_impl(os_int64) CFileReadImpl::GetFileSize()
{
	return m_FileOpt.fSize(m_hFile);
}

std_method_impl CFileReadImpl::ReadBuffer(char* szBuffer,os_int64 ulReadFileLen, os_int64* ulReadSize)
{
	HRESULT		hr	=	S_OK;


	size_t size = ulReadFileLen & UINT32_MAX;

	*ulReadSize = m_FileOpt.Read(m_hFile, szBuffer, size);

	return hr;
}
std_method_impl CFileReadImpl::AsynReadBuffer(const char* szNodeName,char* szNodeInfo)
{
	HRESULT		hr	=	S_OK;

	return hr;
}
